﻿using System;
using System.Collections.Generic;
using System.Linq;
using Mono.Cecil;
using Mono.Cecil.Cil;
using ProjScan.RecordManager;
using ProjScan.RecordManager.AssetData;
using ProjScan.ScanRule.Attr;
using ProjScan.Submodules.CS_Check;
using ProjScan.Tools;

namespace ProjScan.ScanRule.CodeAnalysis
{
	// Token: 0x0200020B RID: 523
	[CSCheckRuleAttr]
	internal class EmptyBodyUpdate : RecordRuleImp<TypeDefinitionAssetData, TypeDefinitionRecordManager>
	{
		// Token: 0x17000357 RID: 855
		// (get) Token: 0x06000F38 RID: 3896 RVA: 0x0000719A File Offset: 0x0000539A
		public override bool HasWhiteList
		{
			get
			{
				return false;
			}
		}

		// Token: 0x06000F39 RID: 3897 RVA: 0x00044094 File Offset: 0x00042294
		protected override string GetFailedColumn()
		{
			return "路径行号";
		}

		// Token: 0x06000F3A RID: 3898 RVA: 0x0000A3A0 File Offset: 0x000085A0
		public override bool HasFailedInfos()
		{
			return true;
		}

		// Token: 0x06000F3B RID: 3899 RVA: 0x000440AC File Offset: 0x000422AC
		protected override string GetDetailCSVHeader()
		{
			return "Class,路径行号";
		}

		// Token: 0x06000F3C RID: 3900 RVA: 0x000440C4 File Offset: 0x000422C4
		protected override string GetDetailInfo(TypeDefinitionAssetData assetData, string failedInfo)
		{
			return base.GetDetailInfo(assetData, failedInfo) + failedInfo;
		}

		// Token: 0x06000F3D RID: 3901 RVA: 0x000440E4 File Offset: 0x000422E4
		protected override bool IsOK(TypeDefinitionAssetData assetData, ref string failedInfo)
		{
			TypeDefinition typeDefinition = assetData.typeDefinition;
			bool flag = assetData.IsDerivedFromMonoBehaviour();
			if (flag)
			{
				List<MethodDefinition> list = Enumerable.ToList<MethodDefinition>(typeDefinition.Methods);
				for (int i = 0; i < list.Count; i++)
				{
					MethodDefinition methodDefinition = list[i];
					bool flag2 = false;
					bool flag3 = Enumerable.Contains<string>(this.CheckFunctionNames, methodDefinition.Name) && (!methodDefinition.HasBody || methodDefinition.Body.Instructions.Count < 3);
					if (flag3)
					{
						foreach (Instruction instruction in methodDefinition.Body.Instructions)
						{
							MethodDefinition methodDefinition2 = instruction.Operand as MethodDefinition;
							bool flag4 = methodDefinition2 != null && methodDefinition2.IsStatic;
							if (flag4)
							{
								flag2 = true;
							}
						}
						bool flag5 = !flag2;
						if (flag5)
						{
							LineMapping mapping = LineMapping.GetMapping(methodDefinition, methodDefinition.Body.Instructions[0]);
							bool flag6 = mapping != null && !string.IsNullOrEmpty(mapping.ToString());
							if (flag6)
							{
								failedInfo = mapping.ToString() + AssemblyTools.I.GetAppendFullName(assetData.typeDefinition);
							}
							else
							{
								failedInfo = "Unknown";
							}
							return false;
						}
						flag2 = false;
					}
				}
			}
			return true;
		}

		// Token: 0x040008F7 RID: 2295
		private string[] CheckFunctionNames = new string[]
		{
			"Update",
			"LateUpdate",
			"FixedUpdate"
		};
	}
}
